package org.summer.lawyer.controller.wx;

import cn.dev33.satoken.annotation.SaCheckLogin;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.summer.common.core.domain.R;
import org.summer.lawyer.domain.vo.feedback.FeedbackCreateVo;
import org.summer.lawyer.service.IFeedbackService;

/**
 * 意见反馈
 *
 * @author summer
 * @date 2024-06-20
 */
@Tag(name = "微信小程序意见反馈和首页留言相关接口", description = "微信小程序意见反馈和首页留言相关接口")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wx/feedback")
public class WxFeedbackController {


    private final IFeedbackService feedbackService;

    @Parameters({
            @Parameter(name = "contactPhone", description = "联系电话", required = true),
            @Parameter(name = "nickname", description = "联系人", required = true),
            @Parameter(name = "feedbackDetail", description = "留言内容", required = true)
    })
    @Operation(summary = "我要留言", description = "首页我要留言")
    @SaCheckLogin
    @PostMapping("/saveMessage")
    public R<Void> saveMessage(@Validated @RequestBody FeedbackCreateVo vo){
        vo.setFeedbackType("1");
        feedbackService.insertByVo(vo);
        return R.ok();
    }

    @Parameters({
            @Parameter(name = "feedbackDetail", description = "留言内容", required = true)
    })
    @Operation(description = "个人中心反馈与意见")
    @SaCheckLogin
    @PostMapping("/saveFeedback")
    public R<Void> saveFeedback(@Validated @RequestBody FeedbackCreateVo vo){
        vo.setFeedbackType("2");
        feedbackService.insertByVo(vo);
        return R.ok();
    }

    @Parameters({
            @Parameter(name = "wxUserId", description = "微信用户ID", required = true),
            @Parameter(name = "bizId", description = "业务ID", required = true),
            @Parameter(name = "bizName", description = "业务名称", required = true),
            @Parameter(name = "feedbackDetail", description = "反馈内容", required = true)
    })
    @Operation(summary = "服务详情我要留言", description = "服务详情我要留言")
    @SaCheckLogin
    @PostMapping("/saveBizFeedback")
    public R<Void> saveBizFeedback(@Validated @RequestBody FeedbackCreateVo vo){
        vo.setFeedbackType("1");
        feedbackService.insertByVo(vo);
        return R.ok();
    }
}
